package com.hxd.otc.module.wallet.activity;

import android.graphics.Bitmap;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.hxd.otc.R;
import com.hxd.otc.base.BaseActivity;
import com.hxd.otc.common.UserHelper;
import com.hxd.otc.mvp.base.BasePresenter;
import com.hxd.otc.utils.AddressUtil;
import com.hxd.otc.utils.ResourceUtil;
import com.hxd.otc.utils.WalletCoinTypes;
import com.hxd.otc.widget.TitleBar;
import com.scwang.smartrefresh.layout.util.DensityUtil;
import com.uuzuche.lib_zxing.activity.CodeUtils;

import butterknife.BindView;

/**
 * 作  者 :  卫广玉
 * 时  间 :  2018/6/8 10:31
 * 描  述 :  收款  無用
 */
public class WalletQuickPayeeActivity extends BaseActivity {


    @BindView(R.id.title_bar)
    TitleBar titleBar;
    @BindView(R.id.iv_wallet_address_qr)
    ImageView ivWalletAddressQr;
    @BindView(R.id.tv_address)
    TextView tvAddress;
    @BindView(R.id.tv_copy_address)
    TextView tvCopyAddress;

    Bitmap bitmap = null;
    @BindView(R.id.tv_address_tips)
    TextView tvAddressTips;

    private String address = "";

    @Override
    protected int getLayoutId() {
        return R.layout.activity_wallet_aec_quick_payee;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {
        address = WalletCoinTypes.getInstance().getAddress(getString(R.string.aec));
        bitmap = CodeUtils.createImage(address, DensityUtil.dp2px(213), DensityUtil.dp2px(213), null);
        ivWalletAddressQr.setImageBitmap(bitmap);
        tvAddressTips.setText(String.format(getString(R.string.wallet_my_wallet_address_tips), UserHelper.getNickName(), "AEC"));
        tvAddress.setText(address);
    }

    @Override
    protected void initEvent() {
        tvCopyAddress.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AddressUtil.copyAddress(WalletQuickPayeeActivity.this, address, ResourceUtil.getString(R.string.wallet_toast_address_copy_success));
            }
        });
    }

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (bitmap != null && !bitmap.isRecycled()) {
            bitmap.recycle();
            bitmap = null;
        }
    }
}